<?xml version="1.0" encoding="utf-8" ?>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>报价记录</title>
		<!-- 引入样式 -->
		<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
		<script src="https://unpkg.com/vue/dist/vue.js"></script>
		<!-- 引入组件库 -->
		<script src="https://unpkg.com/element-ui/lib/index.js"></script>
		<!-- 引入axios -->
		<script src="../js/axios.js"></script>
		<script src="../js/qs.js"></script>
		<!-- 导入jquery -->
		<script src="../js/jquery.min.js"></script>
		<style type="text/css">
.loading{
        width: 100%;
        height: 100%;
        position: fixed;
        background-color: white;
        top: 0px;
        left: 0px;
        z-index: 100;
}	
.loading .bigpic{
    width: 104px;
    height: 104px;
    background-image: url("../imgs/loading.gif") ;
    position: absolute;
    top: 0px;
    bottom: 0px;
    right: 0px;
    left: 0px;
    margin: auto;
}
.select{
width:130px;
}
 .bg-purple {
 
  }
  .grid-content {
    border-radius: 4px;
  }
.undo{
    background-image: url("") ;
}

		</style>


		<!--<style type="text/css">
			//这段代码是让分割线中间加文字
.order {
   height: 60px;
   line-height: 60px;
   text-align: center;
}
 .order .line {
   display: inline-block;
   width: 150px;
   border-top: 1px solid #ccc ;
}
.order .txt {
   color: #686868;
   vertical-align: middle;
}
		</style>-->
	</head>
	<body>
				<!-- 搜索 -->
<!-- 		<div class="loading">
			<div class="bigpic"><div class="bigpic"></div></div>
		</div> -->
		<div id="bigbox" >
 		 <div style="width: 100%;margin-left: 15px;display: block;" > 
				<i class="el-icon-caret-right" style="line-height: 40px;margin-right: 5px; float: left;"></i>
				<template style="margin-top: 50px;">
  			<el-select v-model="value7" placeholder="请选择" multiple style="float: left;width:200px;" @change="handleSelect" @visible-change="visibleChange()" @remove-tag="removeTag()"   >
  			<!-- :key="group.label",:key="item.value" -->
    		<el-option-group v-for="group in options3" :key="group.label"  :label="group.label" >
      		<el-option v-for="item in group.options"  :key="item.value" :label="item.label" :value="item.value">
     		 </el-option>
    		</el-option-group>
 			 </el-select>
				</template>
				<i class="el-icon-search" style="line-height: 40px;float: left;margin-left: 10px; width: 50px; height: 50px;"></i>
				<!-- 搜索框 -->
				<div style="display: block;margin-left: -20px;float: left;">
				<!-- state1Flag=false	 -->
			    <el-autocomplete class="inline-input" v-model="state1" :fetch-suggestions="querySearchAsync" placeholder="请输入内容" @select="handleSelect" @focus="stateManagement(true,1)" @blur="state1Flag=false">
			    	<el-select v-model="select" slot="append" placeholder="请选择" class="select" @change="clearData()">
			      	<el-option label="机会主题" value="1"></el-option>
			      	<el-option label="客户名称" value="2"></el-option>
			      	<el-option label="报价主题" value="3"></el-option>
			    	</el-select>
			    </el-autocomplete>
				</div>
				</div>

				
				<!-- 表单 -->
			<div style="width: 99%;float: left;" id="app2">
				<!-- <div style="float: left;margin-left: 30px;margin-top: -10px;"></div> -->
<el-row :gutter="20">
  <el-col :span="20">
  <div class="grid-content bg-purple" style="padding: 10px 0;">
  <span style="font-size: 13px;color: #333333;">报价单</span> 
	<!--   <div style="width:50px;height:40px;"></div>-->
    <el-tooltip  effect="dark" content="解除搜索，显示全部数据" placement="right" v-show="removeSearch">
      <el-button style="padding:2px 5px; border-radius: 8px;background-color:red;color:white;"v-on:click="removeSearch1()"><img src="../imgs/undo.png" style="width:13px;height:13px;"/><span style="font-size:10px;">解除搜索</span></el-button>
    </el-tooltip>		
  </div>
  </el-col>
  <el-col :span="4"><div class="grid-content bg-purple" style="padding-top:0px;margin-left:40px">
   <el-button size="small" icon="el-icon-circle-plus" v-on:click="loadInfo(0)" @click="dialogFormVisible = true" style="width: 80px;"> 新建</el-button> 
  </div>
  </el-col>
</el-row>  
 <!--这一块代码表示新增弹窗---开始-->
	<div style="float: right;display: block;margin-right: 20px;margin-top: -10px;" @click="deathWindow('form')" >

					<!-- 这里是弹窗--start-->					
					<el-dialog   title="新建报价单" :visible.sync="dialogFormVisible" width="70%"  >
					<hr style="border: 1px solid #000000;margin-top: -15px;" />
						<el-form :model="form" :rules="rules" label-width="150px" ref="form"  style="height: 680px; margin-top: 20px;">
							<el-row >
								<el-col :span="22">
									<el-form-item label="报价主题:" prop="qrTheme" >
										<el-input v-model="form.qrTheme"></el-input>
									</el-form-item>
								</el-col>
								</el-row>															
							<el-row >
								<el-col :span="12">
						<el-form-item label="客户:" prop="customer">
						<!-- :fetch-suggestions="querySearchAsync"customerFlag:false,soltIdFlag:false-->
						<el-autocomplete v-model.trim="form.customer" :fetch-suggestions="querySearchAsync"  placeholder="请输入内容" @select="handleSelect" @focus="customerFlag=true" @blur="customerFlag=false">
						 <i slot="prefix" class="el-input__icon el-icon-search"></i>
						</el-autocomplete>
					    	</el-form-item>
								</el-col>	
						<el-col :span="12">
						<el-form-item label="报价日期:" prop="qrDate">
										<el-date-picker v-model="form.qrDate" align="right" type="date" placeholder=" "  >
										</el-date-picker>
									</el-form-item>
					    	</el-form-item>
						</el-col>
						</el-row>	
						<el-row style="margin-left: 10px;">	
								<el-col :span="12">
									<el-form-item label="总报价:" prop="generalQuotation">
									<el-input v-model.number="form.generalQuotation" style="width:57%;"></el-input>
									</el-form-item>
								</el-col>
						<el-col :span="12">
						<el-form-item label="对应机会:" prop="salTheme">
						<!-- :fetch-suggestions="querySearchAsync"customerFlag:false,soltIdFlag:false-->
							<el-select v-model="form.salesOpportunity" filterable placeholder="未选" @focus="findBySales" required>
							<el-option v-for="item in salesOpportunitys" :key="item.value" :label="item.label" :value="item.value">
							</el-option>
							</el-select>
					    	</el-form-item>
								</el-col>								
						</el-row>	
							<el-row style="margin-left: 10px;">
						<el-col :span="12">								
						<el-form-item label="接收人:" prop="qrReceiver">
							<el-select v-model="form.qrReceiver" filterable placeholder="未选"  required>
							<el-option v-for="item in qrReceivers" :key="item.value" :label="item.label" :value="item.value">
							</el-option>
							</el-select>
					    	</el-form-item>
								</el-col>
						<el-col :span="12">								
						<el-form-item label="报价人:" prop="qrOfferor">
						<!-- :fetch-suggestions="querySearchAsync"customerFlag:false,soltIdFlag:false-->
						<el-autocomplete v-model.trim="form.qrOfferor" :fetch-suggestions="querySearchAsync"  placeholder="请输入内容" @select="handleSelect" @focus="soltIdFlag=true" @blur="soltIdFlag=false">
						 <i slot="prefix" class="el-input__icon el-icon-search"></i>
						</el-autocomplete>
					    	</el-form-item>
								</el-col>
							</el-row>	
						<el-col :span="24">								
						<el-form-item label="报价人联系方式:" prop="qrOfferphone">
						<el-input v-model="form.qrOfferphone" style="width:57%;"></el-input>
						</el-form-item>
							</el-row>							
					<el-row style="margin-left: 10px;">
						<el-form-item label="交付说明:">
						<el-input type="textarea"  style="width:82%" :rows="3"  v-model="form.deliveryInstructions"> </el-input>
						</el-form-item>
						</el-row>							
					<el-row style="margin-left: 10px;">
						<el-form-item label="付款说明:">
						<el-input type="textarea"  style="width:82%" :rows="3"  v-model="form.paymentInstructions"> </el-input>
						</el-form-item>
						</el-row>
					<el-row style="margin-left: 10px;">
						<el-form-item label="包装运输说明:">
						<el-input type="textarea"  style="width:82%" :rows="3"  v-model="form.qrExplain"> </el-input>
						</el-form-item>
						</el-row>					
						<hr style="border: 0.5px solid #EEEEEE;" />						
							<el-form-item style="float: right;margin-top: 40px;">
								<el-button @click="cancelForm('form')">取 消</el-button>
								<el-button type="primary" @click="submitForm('form')" >确定</el-button>
								<el-button @click="resetForm('form')">重置</el-button>
							</el-form-item> 
						</el-form>
					</el-dialog>
					<!--这里是弹窗--end-->
					
				</div>
				</div>
 

		
				<!--这一块代码表示新增弹窗---结束-->     	
							
    		<!--这一块代码表示表格的显示---开始-->	
			<!-- 表单 -->
			<div id="app3" >
			<!-- element-loading-spinner="el-icon-loading" element-loading-text="拼命加载中"-->
			
			<div id="print"  >
			<!-- printStart -->
					<el-table ref="multipleTable" tooltip-effect="dark" @selection-change="handleSelectionChange" :data="tableData3"
					 v-loading="tableloading"   :cell-style="cellStyle" :header-cell-style="cellStyle" 
						 border style="border:1px solid #ebeef5;width: 100%;"
					  element-loading-background="rgba(0, 0, 0, 0)"  >
						<el-table-column type="selection" width="35" v-if="printFlag1==false" >
						</el-table-column>				
						<el-table-column prop="qdRecordId" label="ID" >
						</el-table-column>
						<el-table-column prop="qrTheme" label="报价主题">
						</el-table-column>
						<el-table-column prop="customer" label=" 客户">
						</el-table-column>
						<el-table-column prop="qrReceiver" label="接收人" >
						</el-table-column>			
						<el-table-column prop="salTheme" label="对应机会" >
						</el-table-column>					
						<el-table-column prop="generalQuotation" label="总报价" >
						</el-table-column>
						<el-table-column prop="qrOfferor" label="报价人" >
						</el-table-column>
						<el-table-column prop="qrDate" label="报价日期" >
						</el-table-column>
						<el-table-column fixed="right" label="操作" width="120px" v-if="printFlag2==false" >
							<template slot-scope="scope">
							<el-tooltip content="Bottom center" placement="bottom" width="50px">
							 <div slot="content">生成订单</div>
								<i class="el-icon-edit-outline" style="margin: 0px 2px;font-size: 17px;" @click="changeToOrder(scope.row.qdRecordId)"></i>
							</el-tooltip>
								<el-tooltip content="Bottom center" placement="bottom">
									<div slot="content">编辑</div>								
									<i class="el-icon-edit" v-on:click="loadInfo(scope.row.qdRecordId)" @click="dialogrepair = true" style="font-size: 17px;"></i>
								</el-tooltip>
									<el-tooltip content="Bottom center" placement="bottom">
									<div slot="content">删除</div>
									<i class="el-icon-delete" style="margin: 0px 10px;font-size: 17px;"  @click="DeleteShow(scope.row.qdRecordId)" ></i>
								</el-tooltip>							
							</template>
						</el-table-column>
						
					</el-table>
				</div>			
			<!--这一块代码表示表格的显示---结束-->		
				<!--这一块代码表示的删除提示弹窗---开始-->	
					<el-dialog title="提示" :visible.sync="dialogDelete" width="30%" append-to-body>
					 	 <span>你确定要删除吗？</span>
					  	<span slot="footer" class="dialog-footer">
					    <el-button @click="dialogDelete = false">取 消</el-button>
					    <el-button type="primary" @click="dialogDelete = false" v-on:click="Delete" >确 定</el-button>
					  </span>
					</el-dialog>
					<!--这一块代码表示的删除提示弹窗---结束-->	
					
<!--这一块代码表示新增弹窗---开始-->
	<div style="float: right;display: block;margin-right: 20px;margin-top: -10px;" @click="deathWindow('form')" >

					<!-- 这里是弹窗--start-->					
					<el-dialog   title="修改报价单" :visible.sync="dialogrepair" width="70%"  >
					<hr style="border: 1px solid #000000;margin-top: -15px;" />
						<el-form :model="form" :rules="rules" label-width="150px" ref="form"  style="height:1080px; margin-top: 20px;">
							<el-row >
								<el-col :span="22">
									<el-form-item label="报价主题:" prop="qrTheme" >
										<el-input v-model="form.qrTheme"></el-input>
									</el-form-item>
								</el-col>
								</el-row>															
							<el-row >
								<el-col :span="24">
						<el-form-item label="客户:" prop="customer">
						<!-- :fetch-suggestions="querySearchAsync"customerFlag:false,soltIdFlag:false-->
						<el-autocomplete v-model.trim="form.customer" :fetch-suggestions="querySearchAsync"  placeholder="请输入内容" :disabled="true" @select="handleSelect" @focus="customerFlag=true" @blur="customerFlag=false">
						 <i slot="prefix" class="el-input__icon el-icon-search"></i>
						</el-autocomplete>
					    	</el-form-item>
								</el-col>
							</el-row>	
						<el-row >
						<el-col :span="24">
						<el-form-item label="报价日期:" prop="qrDate">
										<el-date-picker v-model="form.qrDate" align="right" type="date" placeholder=" "  >
										</el-date-picker>
									</el-form-item>
					    	</el-form-item>
						</el-col>
						</el-row>	
						<el-row style="margin-left: 10px;">	
								<el-col :span="12">
									<el-form-item label="总报价:" prop="generalQuotation">
									<el-input v-model.number="form.generalQuotation" style="width:57%;"></el-input>
									</el-form-item>
								</el-col>
						<el-col :span="12">
						<el-form-item label="对应机会:" prop="salTheme">
						<!-- :fetch-suggestions="querySearchAsync"customerFlag:false,soltIdFlag:false-->
							<el-select v-model="form.salesOpportunity" filterable placeholder="未选" @focus="findBySales" required>
							<el-option v-for="item in salesOpportunitys" :key="item.value" :label="item.label" :value="item.value">
							</el-option>
							</el-select>
					    	</el-form-item>
								</el-col>									
						</el-row>	
						<div>
						<span style="color:blue;cursor:pointer;" @click="showQR">编辑报价单明细</span>
					<el-table ref="multipleTable" :summary-method="getSummaries" show-summary  border :data="qd"  tooltip-effect="dark"
					 style="width: 100%;background-color: #dee1e6;color: black;"  maxhight="120px"  >

						<el-table-column prop="qdProduct" label="产品名" width="200px" align="center">
						</el-table-column>
						<el-table-column prop="qdUnit" label="单位" align="center">
						</el-table-column>
						<el-table-column prop="qdPrice" label="单价" align="center">
						</el-table-column>
						<el-table-column prop="qdNumber" label="数量" align="center">
						</el-table-column>
						<el-table-column prop="discount" label="折扣" align="center">
						</el-table-column>
						<el-table-column prop="money" label="金额" align="center"> 
						</el-table-column>
						<el-table-column prop="qdNotes" label="备注" align="center">
						</el-table-column>
					</el-table>						
						</div>
							<el-row style="margin-left: 10px;">
						<el-col :span="12">								
						<el-form-item label="接收人:" prop="qrReceiver">
							<el-select v-model="form.qrReceiver" filterable placeholder="未选"  required>
							<el-option v-for="item in qrReceivers" :key="item.value" :label="item.label" :value="item.value">
							</el-option>
							</el-select>
					    	</el-form-item>
								</el-col>
						<el-col :span="12">								
						<el-form-item label="报价人:" prop="qrOfferor">
						<!-- :fetch-suggestions="querySearchAsync"customerFlag:false,soltIdFlag:false-->
						<el-autocomplete v-model.trim="form.qrOfferor" :fetch-suggestions="querySearchAsync"  placeholder="请输入内容" @select="handleSelect" @focus="soltIdFlag=true" @blur="soltIdFlag=false">
						 <i slot="prefix" class="el-input__icon el-icon-search"></i>
						</el-autocomplete>
					    	</el-form-item>
								</el-col>
							</el-row>	
						<el-col :span="24">								
						<el-form-item label="报价人联系方式:" prop="qrOfferphone">
						<el-input v-model.number="form.qrOfferphone" style="width:57%;"></el-input>
						</el-form-item>
							</el-row>							
					<el-row style="margin-left: 10px;">
						<el-form-item label="交付说明:">
						<el-input type="textarea"  style="width:82%" :rows="3"  v-model="form.deliveryInstructions"> </el-input>
						</el-form-item>
						</el-row>							
					<el-row style="margin-left: 10px;">
						<el-form-item label="付款说明:">
						<el-input type="textarea"  style="width:82%" :rows="3"  v-model="form.paymentInstructions"> </el-input>
						</el-form-item>
						</el-row>
					<el-row style="margin-left: 10px;">
						<el-form-item label="包装运输说明:">
						<el-input type="textarea"  style="width:82%" :rows="3"  v-model="form.qrExplain"> </el-input>
						</el-form-item>
						</el-row>					
						<hr style="border: 0.5px solid #EEEEEE;" />						
							<el-form-item style="float: right;margin-top: 40px;">
								<el-button type="primary" @click="submitForm('form')" >确定</el-button>
								<el-button @click="resetForm('form')">重置</el-button>
							</el-form-item> 
						</el-form>
					</el-dialog>
					<!--这里是弹窗--end-->
					
				</div>
				</div>
 

		
				<!--这一块代码表示新增弹窗---结束-->      						
					
					<!--这一块代码最下方的分页、打印和导出Excel---开始-->
					<div style="margin-top: 10px">
						<div style="display: block; float: left;margin-left: 5px;">
							<el-tooltip content="Bottom center" placement="bottom">
								<div slot="content">删除</div>
								<i class="el-icon-delete" style="margin: 8px;font-size: 17px;"></i>
							</el-tooltip>
						</div>
						<!-- 分页 -->
						<div style="display: block; float: left; margin-left: 300px;">
							<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage4"
							 :page-sizes="page.pageCentent" :pager-count="5" :page-size="100" layout="total, sizes, prev, pager, next, jumper" :total="page.AllpageNumber">
							</el-pagination>
						</div>
						
						<div style="display: block; float: right;margin-right: 15px;">
							<el-tooltip content="Bottom center" placement="bottom">
								<div slot="content">打印</div>
								<el-button circle size="mini"><i class="el-icon-printer" style="font-size: 17px;" @click="print(7)"></i></el-button>&nbsp;
							</el-tooltip>

							<el-tooltip content="Bottom center" placement="bottom">
								<div slot="content">导出Excel</div>
								<el-button circle size="mini"><i class="el-icon-tickets" style="font-size: 17px;"></i></el-button>
							</el-tooltip>

						</div>
					</div>
				</template>
			</div>
	</div><!--这个/div是id="bigbox"的-->
	</div>
<!--这一块代码最下方的分页、打印和导出Excel---结束-->
		<!-- src="../js/sales/saleOpp.js" -->
	<script type="text/jscript" >
					var Main1 = {
						data() {

						    //检查机会主题是否重复，是否为空    
							   var checkQrTheme = (rule, value, callback) => {
								   if(value==null||value==''){
									   callback(new Error('机会主题为必填项'));  
								   }
								   var _this=this;
								 	axios.get("/sales/findBySalTheme",
						           			{
										params:{
											salTheme:value
												}
				           					}
						           			//ajax请求成功的回调函数
						          			).then(function(response){					          				
						           			console.log("回调成功，获取了服务器端返回的值v");
						           			console.log(response.data);//返回id值
						           			console.log(_this.form.salId);
						           			if(response.data){
						           				if(_this.form.salId==response.data){
						           					callback();						           					
						           				}else{
										           	 callback(new Error('该机会主题已存在，请重新命名'));							           					
						           				}
					           				
						           			}else{
						           				callback();
						           			}
						           	}).catch(function(){
						           	 callback(new Error('查询有误'));
						           	});
								 	
							       };
							 //检查签单预计时间是否大于等于今天      
						      var  checkQrDate=(rule, value, callback) => {
						    	  //Thu Jul 12 2018 00:00:00 GMT+0800 (中国标准时间)
						    	  	//将当前日期转换成yyyy-MM-dd格式
						    	  	//var selectDate = value.format('yyyy-MM-dd');
									//alert(this.form.salTheme);
						    	 	 //将当前时间转换成yyyy-MM-dd
						    	 	 if(value==null||value==''){
						    	 		 callback();
						    	 	 }else{
						    	 		/* if(this.form.salId!=null){
						    	 			 
						    	 		 }*/
											var t2 =0;
						    	 		 try{
						    	 			 t2=new Date(value.replace("-", "/").replace("-", "/"));
						    	 			callback();
						    	 		 }catch(err)
						    	 		 {
									    	   var mydate = new Date();
												var str1 = "" + mydate.getFullYear() + "-";
												str1 += (mydate.getMonth()+1) + "-";
												str1 += mydate.getDate();
									    	 	 //将获取的时间转换成yyyy-MM-dd								    	 	 
													var str2 = "" + value.getFullYear() + "-";
													str2 += (value.getMonth()+1) + "-";
													str2 += value.getDate();
										    	//可将yyyy-MM-dd格式转成可以进行比较的yyyy/MM/dd格式										
												var tady=new Date(str1.replace("-", "/").replace("-", "/"));
							    	 			 t2=new Date(str2.replace("-", "/").replace("-", "/"));
									          setTimeout(() => {
									            if (t2<tady) {
									              callback(new Error('签单时间不能小于今天'));
									            } else {
									                callback();
									            }
									          }, 1000);												
									       };

						    	 	 }
							       };
							     //检查输入的客户数据是否存在,是否为空  
								 var checkCustomer = (rule, value, callback) => {
									   if(value==null||value==''){
										   callback(new Error('对应客户为必填项'));  
									   }
								          setTimeout(() => {
								            if (this.restaurants==null||this.restaurants=='') {
								              callback(new Error('您输入的客户名称不存在，请确认后再输入'));
								            } else {
								                callback();
								            }
								          }, 1000);
								   };							
						return {
								qd:'',
								tableData3:${salesOpp},//表格数据
								currentPage1: 5,//分页数据
								currentPage2: 5,//分页数据
								currentPage3: 5,//分页数据
								currentPage4: 4,//分页数据
								multipleSelection: [],
								dialogrepair: false,
								dialogDelete:false,
								tableloading:false,
								removeSearch:false,								
						          value7:'',
						          value7Copy:'',
						          printFlag1:false,//这个值是为了在打印的时候去掉一些不必要的元素
						          printFlag2:false,//这个值是为了在打印的时候去掉一些不必要的元素
						          value7Flag:false,
						          option:'',
						          obj2:null,
						          state1:'',
						          state1Copy:'',
						          salStageCopy:'',//这个是销售机会负责人的copy
						          matchFlag:false,
						          state1Flag:false,
						          state1Session:false,
						          select:'1',
						          selectCopy:'1',
									form: {
										generalQuotation:'',//	总报价
										deliveryInstructions:'',//交付说明
										qrTheme:'',//报价主题
										paymentInstructions:'',//付款说明
										qrExplain:'',//包装运输说明
										qrOfferphone:'',//报价人联系方式
										quotationFile:'',//上传附件									
										qrReceiver:'',//接收人,就是联系人									
										salesOpportunity:'',//销售机会机会主题
										qrOfferor:'',//报价人，用户
										customer:'',//客户的数据
										state:1,//状态值，好像没有用到
										qrDate:'',//报价日期
										qdRecordId:'',//报价记录id
									},
								/*								
								 * 下面这一段表示在搜索选择是获取对应的选择值，但是这个在有连级的情况下才需要写
								 * salId：在修改时获取对应的id传到后台
								 * */
								qdRecordId:'',//报价记录id
								salId:'',
								gdID: '',//这个是获取了客户的id
								conID:'',//获取联系人id
								userId:'',
								qrReceivers:'',
								salesOpportunitys:'',
								rules:{
									customer:[
									{	
										required: true,validator:checkCustomer, trigger: 'change'
									}],
									qrTheme:[{
										required: true,validator:checkQrTheme, trigger: 'blur'										
									}],
									qrDate:[{
										required: true,validator:checkQrDate, trigger: 'blur'	
									}],
								},
							        options3: [
							        	{
								            label: '全部数据',
								            options: [{
								            	label:'全部数据',
								            	value:''
								            	}]						        		
							        	}],
		/*这里的查询变量和variable_form文件中的变量具有共同性*/
							/* 	salesOpportunityTrackingLogs:'', *///这个值是为了显示销售机会跟踪日志
								page:{
									pageCentent:[4, 6, 10],	
									AllpageNumber:${salesCount}
								},
								pageNumber:1,								
								pageCententSelect:4,								
								value8: '',
								valuecust: '',
								DId:0,
								data:[],
								flag:false,
								dialogFormVisible: false,
								customerFlag:false,
								soltIdFlag:false,
								
								/* 日期选择 */
								pickerOptions1: {
									disabledDate(time) {
										return time.getTime() > Date.now();
									},
									shortcuts: [{
										text: '今天',
										onClick(picker) {
											picker.$emit('pick', new Date());
										}
									}, {
										text: '昨天',
										onClick(picker) {
											const date = new Date();
											date.setTime(date.getTime() - 3600 * 1000 * 24);
											picker.$emit('pick', date);
										}
									}, {
										text: '一周前',
										onClick(picker) {
											const date = new Date();
											date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
											picker.$emit('pick', date);
										}
									}]
								},
								gettoday: new Date(),
								getDate:'',
								gettime: new Date(),
								prostarttoday:'',
								prosalettoday:'',
						        restaurants: [],
						        timeout:  null
							}							
						},
						methods: {
							//生成订单的方法
							changeToOrder(id){
								var _this=this;
							 	axios.get("/sales/changeToOrder",
					           			//参数转换
					           			//Qs.stringify(this.form,{arrayFormat: 'brackets'})
					           			//ajax请求成功的回调函数
					           			{
							 		params:{
							 			qId:id
							 		}
					           			}
					          			).then(function(response){					          				
					           			console.log("回调成功，获取了服务器端返回的值v");
					           			console.log(response.data);
					           		
					           				
 					           			if(response.data==1){
						           			_this.$notify({
							           	          title: '已生成订单',
							           	          type: 'success',
							           	       	  duration:3000
							           	        });					           				
					           			}else{
						           			_this.$notify({
							           	          title: '生成失败,可能缺少报价单明细',
							           	          type: 'success',
							           	       	  duration:3000
							           	        });						           				
					           			} 
					           	}).catch(function(){
					           		alert("加载销售机会信息出错了");
					           	});	
							},
							//跳转到编辑报价单明细
							showQR(){
								window.open("sales/quotationDetail?id="+this.form.qdRecordId);  
							},
							//这个方法用于计算报价明细的总计
							getSummaries(param) {
								const {
									columns,
									data
								} = param;
								const sums = [];
								columns.forEach((column, index) => {
									if (index === 0) {
										sums[index] = '总计';
										return;
									}
									const values = data.map(item => Number(item[column.property]));
									if (!values.every(value => isNaN(value))) {

										sums[index] = values.reduce((prev, curr) => {
											const value = Number(index);
											if (!isNaN(value) || index != 5) {
												return prev + curr;
											} else {
												return '';
											}
										}, 0);
										if (index == 2|| index == 0 || index == 6) {
											sums[index] = '';
										}
										if (index ==3 || index == 4)
											sums[index] = '---';
										if (index == 5) {
											sums[index] = sums[index].toFixed(2);
											sums[index] += '元';
										}
									} else {
										sums[index] = '';
									}
								});
								return sums;
							},
							//通过客户id查询对应的销售机会
							findBySales(){
								var _this=this;
								if(this.gdID!=null||this.gdID!=0){
								 	axios.get("/sales/abroadsolutionsales",
						           			//参数转换
						           			//Qs.stringify(this.form,{arrayFormat: 'brackets'})
						           			//ajax请求成功的回调函数
						           			{
								 		params:{
								 			custID:this.gdID
								 		}
						           			}
						          			).then(function(response){					          				
						           			console.log("回调成功，获取了服务器端返回的值v");
						           			console.log(response.data);
											_this.salesOpportunitys=response.data;
						           	}).catch(function(){
						           		alert("加载销售机会信息出错了");
						           	});											
								}
 															
							},							
							/*
							加载表单时的初始化
							*/						
							initForm(json,_this,id){
			           			var form='';
		           				form=_this.form;

							  if(id!=0){
				           			form.qdRecordId=id+'';	
			           				form.qrDate=_this.toString(json.qrDate);
							  }else{
								form.qdRecordId=null;
			           			form.qrDate=new Date();								
							  }
								/*if(json==" "&&form.salId!=null){

									this.$refs['form'].resetFields();								  
								}*/

			           			//console.log(json.customerName);
		           				form.customer=_this.toString(json.customerName);
		           				_this.gdID=_this.toString(json.customerId);	
		           				form.qrTheme=_this.toString(json.qrTheme);
		           				form.generalQuotation=_this.toString(json.generalQuotation);
		           				form.deliveryInstructions=_this.toString(json.deliveryInstructions);
		           				form.qrExplain=_this.toString(json.qrExplain);
		           				form.qrOfferphone=_this.toString(json.qrOfferphone);
		           				form.quotationFile=_this.toString(json.quotationFile);
		           				form.qrReceiver=_this.toString(json.qrReceiver);
		           				_this.conID=json.conID;
		           				form.qrOfferor=_this.toString(json.qrOfferor);
		           				_this.userId=json.userId;
	           				
		           				form.salesOpportunity=_this.toString(json.salesOpportunityName);
		           				_this.salId=json.salesOpportunityId;
		           				         				
					           				           		           			
							},
							//强制转换成String类型
							toString(val){
							return val==null?'':(val+'');
							},
							DeleteShow(id){
								this.qdRecordId=id;
								this.dialogDelete=true;
								
							},

							//优化处理弹框事件
							deathWindow(formName){						
								if(this.dialogFormVisible==false){
									this.$refs[formName].clearValidate();	
									this.salesOpportunityTrackingLogs=null;
								}
							},

						      //这个是表单重置方法
						     resetForm(formName) {
						        this.$refs[formName].resetFields();
						      },
						      //这个是表单的取消方法
						      cancelForm(formName){
						    	  this.salesOpportunityTrackingLogs=null;
						    	  this.dialogrepair = false;
						    	  this.dialogFormVisible = false;
						    	  this.$refs[formName].clearValidate();
						      },							
							//删除方法
							Delete(){
								var _this=this;
							
								axios.get("/sales/quotationRecordDelete",
					           			//参数转换
					           			//Qs.stringify(this.form,{arrayFormat: 'brackets'})
					           			//ajax请求成功的回调函数
					           			{
											params:{
												salId:this.qdRecordId
											}
					           			}
					          			).then(function(response){					          				
					           			console.log("回调成功，获取了服务器端返回的值v");
					           			console.log(response.data);

					           			//alert(_this.count);
						           			_this.$notify({
							           	          title: '删除成功',
							           	          type: 'success',
							           	       	  duration:3000
							           	        });
						           			/*
						           			-----------------------------刷新当前表单信息
						           			*/
						           			_this.page.AllpageNumber=_this.page.AllpageNumber-1;	
											console.log("当前页: "+_this.pageNumber);
											console.log("每页默认显示的条数:"+_this.pageCententSelect);
											_this.tableloading=true;
										 	axios.get("/sales/quotationRecordPageable",
								           			{
								           		params: {
								          				pageNumber:_this.pageNumber,
								          				pageCentent:_this.pageCententSelect,
								          				DId:_this.DId
								          			    }
								           			}
								           			//ajax请求成功的回调函数
								          			).then(function(response){					          				
								           			console.log("回调成功，获取了服务器端返回的值v");
								           			console.log(response.data);
													_this.tableData3=response.data.saleOpp;
													_this.page.AllpageNumber=response.data.salesCount;
								     		 _this.tableloading=false;	
								           	}).catch(function(){
								           		alert("显示客户数据出错了");
								           	});	
										 	
					           			}).catch(function(){						           				
					           				alert("删除信息出错了");
					           			});
							},								
							loadInfo(id){
								 // `this` 在方法里指向当前 Vue 实例	

								alert(id);
										
									var _this = this;
				           			var form='';
			           				form=_this.form;
								 	
									/*
									* ------------------这个是修改的时候加载销售机会信息
									*/	 
									if(id!=0){
										 	axios.get("/sales/findOnequotationRecord",
								           			//参数转换
								           			//Qs.stringify(this.form,{arrayFormat: 'brackets'})
								           			//ajax请求成功的回调函数
								           			{
										 		params:{
										 			salId:id
										 		}
								           			}
								          			).then(function(response){					          				
								           			console.log("回调成功，获取了服务器端返回的值v");
								           			console.log(response.data);
								           			_this.initForm(response.data[0],_this,id);
								           			//_this.salesOpportunityTrackingLogs=response.data[1].UName+;
								           	}).catch(function(){
								           		alert("加载单个销售机会信息出错了");
								           	});	
										 	
										 	axios.get("/sales/showQuotationDetail",
								           			//参数转换
								           			//Qs.stringify(this.form,{arrayFormat: 'brackets'})
								           			//ajax请求成功的回调函数
								           			{
										 		params:{
										 			id:id
										 		}
								           			}
								          			).then(function(response){					          				
								           			console.log("回调成功，获取了服务器端返回的值v");
								           			console.log(response.data);
													_this.qd=response.data;
								           	}).catch(function(){
								           		alert("加载销售机会信息出错了");
								           	});	 	
									}else{
										_this.initForm(" ",_this,id);
										
									}
									
							},							
						      //这里是加载外表，对应客户的方法
						     abroadsaleCustName() {
							   var _this=this;
							   //AllpageNumber			   
							 	axios.get("/sales/abroadsaleCustName",
						           			{
						           		params: {
						           			custName:_this.customer
						          			    }
						           			}
						           			//ajax请求成功的回调函数
						          			).then(function(response){					          				
						           			console.log("回调成功，获取了服务器端返回的值v");
						           			console.log("修改:"+response.data);					           		
						           		_this.restaurants=response.data;
						           	}).catch(function(){
						           		alert("加载外表,显示客户初始化数据出错了");
						           	});	//这个是数据的初始化
					          
							      },							

									//相当于一种会话，要一次会话结束之后才会变为初始值，废弃
										stateManagement(item,index){
											if(index==1){
												this.state1Flag=item;
												if(this.state1Flag){
													this.state1Session=true;
												}
											}

										},
										//1.当选择其他字段时，清除数据筛选条件中的之前字段的搜索条件
										//2.当字段数据为空时，清除搜索条件
										//3.当字段数据为非比配数据值时，清除搜索条件
										
										//1.是否切换了字段搜索，就将之前的搜索条件删除（不管是否存在），删除时判断是否有不分组条件，存在就设置删除3个元素，否则则为2个元素
										//2.当搜索框搜索条件不存在或者为空时，清除搜索条件，如果存在则保留
										clearData(){	
											console.log("触发方法clearData清除搜索条件判断");	
											console.log("olddata:"+this.data);
											console.log("select:"+this.select);
											console.log("输入框当前值:"+this.state1);	
											var del=null;
											var i=0;
											if(this.selectCopy=='1'){
												del='机会主题';
											}else if(this.selectCopy=='2'){
												del='客户名称';
											}else{
												del='报价主题';
											}
											if(this.selectCopy!=this.select){						
												console.log("del:"+del);
												this.data.find((a)=>{									
													if(a==del){
														console.log("a:"+a);
														if(this.data[i+1]=='不分组'){
															this.data.splice(i,3);											
														}else{
															this.data.splice(i,2);											
														}										
													}
													i++;
												});	
											this.selectCopy=this.select;
											}else{
												var flag=this.isMatch();
												console.log("搜索框的值是否匹配:"+flag);								
												if(!flag){
													this.data.find((a)=>{									
														if(a==del){
															console.log("进入:"+flag);
															console.log("a:"+a);
															if(this.data[i+1]=='不分组'){
																this.data.splice(i,3);											
															}else{
																this.data.splice(i,2);											
															}										
														}
														i++;
													});										
												}
											}
											console.log("newdata:"+this.data);																						
										},
										//判断是否匹配，采用方案为直接判断当前搜索框结果列表是否存在相同的值
										isMatch(){
											//1.当前的搜索框结果列表没有数据时，则判定为不存在匹配值，返回false
											//2.当前的搜索框结果列表有数据时,厉遍搜索框结果列表数据，如果不存在匹配值则返回false，否则返回true
											//3.当前的搜索框结果列表有数据时且搜索框结果列表数据有且只有只有一条数据，则直接返回true
											
											console.log("触发方法isMatch搜索框的值是否匹配"); 
											console.log("当前的搜索框结果列表数据长度:"+this.restaurants.length);	
											var i=0;
											var obj=false;
											if(this.restaurants.length==0){
												return false;
											}else if(this.restaurants.length==1){
												return true;
											}else{
												this.restaurants.find((a)=>{
													if(this.restaurants[i].value==this.state1){
														obj=true;
													}																				
													i++;
												});
												
												if(obj){
													return true;
												}
												return false;
											}
											
										},						
										//1.当字段不变时，替换原来的字段数据
										//2.当字段不变时,判断搜索框的值是否存在变化,没有变化则index索引值返回0,否则返回index
										//3.当字段不变时且输入宽的值和copy都为初始值时，放回flag=true
										checkData(){
											console.log("触发方法checkData搜索框字段不变时，替换原来的字段数据");
											console.log("olddata:"+this.data);
											console.log("select:"+this.select);
											console.log("输入框当前值:"+this.state1);
											var del=null;
											var i=0;
											var index=0;
											var obj={flag:true,index:index};
											
											if(this.state1Copy!=this.state1||this.state1Copy==''){
												if(this.select=='1'){
													del='机会主题';
												}else if(this.select=='2'){
													del='客户名称';
												}else{
													del='报价主题';
												}
												console.log("del:"+del);
												this.data.find((a)=>{									
													if(a==del){
														console.log("a:"+a);	
														index=i+1;
													}
													i++;
												});
												if(index>0){
												obj={flag:false,index:index};
												}
												console.log("index:"+index);	
												console.log("data的长度:"+this.data.length);
												this.state1Copy==this.state1;
											
											}else{
												if(this.state1==''){
													obj={flag:true,index:0};	
												}else{
													obj={flag:false,index:0};
												}
												
												
											}
											
											return obj;	
										},
												      //搜索框，判断是否要进行分组查询
												      isGroup(flag){
												    	  var del=null;
												    	  var i=0;
												    	  var index=0;
												    	  var obj=true;
														    console.log("触发isGroup方法判断是否进行分组查询:"+flag);								    	  
														    console.log("Olddata:"+this.data);
															if(this.selectCopy=='1'){
																del='机会主题';
															}else if(this.selectCopy=='2'){
																del='客户名称';
															}else{
																del='报价主题';
															}
															this.data.find((a)=>{									
																if(a==del){
																	console.log("a:"+a);
																	index=i;
												           			if(this.data[i+1]=='不分组'&&flag){
																		flag=false;
																		index=0;
												           			}
																}
																i++;
															});

												    	  if(flag){
												    		  if(index>0){
																	index=index+1;
																	this.data.splice(index,0,'不分组');									    			  
												    		  }
															
												    	  }else{
												    		  index=index+1;	
												    		  if(this.data[index]=='不分组'){	
												    			console.log("ffffffff:");							    			  
																this.data.splice(index,1);								    			  									    								    			  
												    		  }

													    		  
												    	  }
														   console.log("newdata:"+this.data);
												      },							      
												      //这里是处理搜索框查询字段选择的方法
												      searchSelect(item){
												    	  console.log("item:"+item.value); 
																var _this = this;											    	
													    		_this.matchFlag=true;												
																var data=null;
																this.tableloading=true;
																//this.clearData();//剔除搜索宽里的分页条件
																//this.data.push('');
																var obj=this.checkData();
																if(obj.index>0){
																	if(item.value!=null){
													           			if(this.data[obj.index]=='不分组'){
																			this.data[obj.index+1]=item.value;									           				
													           			}else{
																			this.data[obj.index]=item.value;	
													           			}														
																	}

																
																}
																this.checkData();//这
																 this.isGroup(true);
																data=''+this.data;
											           			console.log("data:"+data);												
																  //post提交数据
													           	axios.get("/sales/quotationRecordPageable",
													           			{
													           		params: {
													          				pageNumber:1,
													          				pageCentent:4,
													          				DId:data
													          			    }
													           			}
													           			//ajax请求成功的回调函数
													          			).then(function(response){					          				
													           			console.log("回调成功，获取了服务器端返回的值v");
													           			console.log(response.data);
													           		//this.tableData3=response.data;
																	_this.tableData3=response.data.saleOpp;
																	_this.page.AllpageNumber=response.data.salesCount;
													     		 _this.tableloading=false;	
													           	}).catch(function(){
													           		alert("分页数据出错了");
													           	});												    		
												    	  
												    	  
									    	  
												      },
												   	  //这里是筛选查询的方法,有点小问题
												   	 screenQueries(){
												    	  var _this=this;
												    	  var obj=null;
												    	  /*
												    	---------------------------------------数据筛选查询  
												    	 */
												    	 
												    	 console.log("option:"+_this.option);
															var data=new Array();
															var i=0;
															var index=0;
												    	  _this.option.find((a)=>{
													    	  console.log("option:"+a.OldDId+"\t"+a.parent);
													    	_this.data.find((b)=>{
																if(b===a.parent||a.parent=='全部数据'){
																	index=i;
																}
																i++;
													    	  });

													    	 if(index>0){
														    	  console.log("index:"+index);
														    	  if(a.count==2){
															    	  console.log("parent"+a.parent);	
														    		  _this.data[i-1]=a.newDId;	
														    	  }else{
														    		  _this.data[i-1]=a.OldDId;								    		  
														    	  } 									    		 
													    	 }else{
														    	  if(a.count==2){
														    		  _this.data.push(a.parent);
														    		  _this.data.push(a.newDId);	
														    	  }else{
														    		  _this.data.push(a.parent);	
														    		  _this.data.push(a.OldDId);								    		  
														    	  }
													    	 }
				 									    	  
													    	  });	
															this.clearData();//剔除搜索宽里的分页条件								    	  	  
													    	  data=''+_this.data;
													    	  console.log("data:"+data);	
													    	  _this.tableloading=true;
														 	axios.get("/sales/quotationRecordPageable",
												           			//参数转换
											           			//Qs.stringify({ids:_this.value7}, {arrayFormat: 'indices'})
											           			{
												           		params:{
											          				pageNumber:1,
											          				pageCentent:4,		
												           			DId:data
												           		}
												           												 		
											           			}

												           			//json.stringify(this.form)
												           			//ajax请求成功的回调函数
												          			).then(function(response){
														           			console.log("回调成功，获取了服务器端返回的值v");
														           			console.log(response.data);
														           			//console.log(response.data.salesCount);/
																_this.tableData3=response.data.saleOpp;
																_this.page.AllpageNumber=response.data.salesCount;
												           	//	this.AllpageNumber=this.count/response.data.length;
												     		//  _this.tableData3 = response.data;	
																  _this.tableloading=false;
																_this.value7Copy=_this.value7;//copy值记录value的变化值
												           	}).catch(function(){
												           		//_this.form.customer=i;
												           		alert("筛选查询出错了");
												           	});	

												      },

												      //这里是加载内表，对应客户的方法
												      withinsaleCustName(){
												    	  var _this=this;
												    	  this.isGroup(false);
										           			console.log("Data:"+_this.data);
										           			var data=''+_this.data;
														 	axios.get("/sales/withinsaleCustName",
												           			{
												           		params: {
												           			DId:data
												          			    }
												           			}
												           			//ajax请求成功的回调函数
												          			).then(function(response){					          				
												           			console.log("回调成功，获取了服务器端返回的值v");
												           			console.log("修改:"+response.data);					           		
												           		_this.restaurants=response.data;
												           	
												           	}).catch(function(){
												           		alert("加载内表,显示客户初始化数据出错了");
												           	});	//这个是数据的初始化								    	  
												      },
												      //这里是加载销售机会主题的方法
												   withinSaleFindByTheme(){
												    	  var _this=this;
										           			console.log("Data:"+_this.data);
										           			var data=''+_this.data;
														 	axios.get("/sales/withinCompetitorFindByTheme",
												           			{
												           		params: {
												           			DId:data
												          			    }
												           			}
												           			//ajax请求成功的回调函数
												          			).then(function(response){					          				
												           			console.log("回调成功，获取了服务器端返回的值v");
												           			console.log("修改:"+response.data);					           		
												           		_this.restaurants=response.data;
												           		
												           	}).catch(function(){
												           		alert("加载销售机会主题数据出错了");
												           	});	//这个是数据的初始化								    	  
												      },

												      //这里是加载内表，负责人的方法
												     withinCompetitorFindByComName(){
												    	  var _this=this;
												    	  this.isGroup(false);//查询分组
										           			console.log("Data:"+_this.data);
										           			var data=''+_this.data;											 
															 	axios.get("/sales/withinquotationRecordTheme",
													           			//参数转换
													           			//Qs.stringify(this.form,{arrayFormat: 'brackets'})
													           			//ajax请求成功的回调函数
													           			{
															 				params:{
															 					DId: data
															 				}
													           			}
													          			).then(function(response){					          				
													           			console.log("回调成功，获取了服务器端返回的值v");
													           			console.log("user:"+response.data);
																	/*
																	users:[
																	{
																		value: '选项1',
																		label: '用户名1'					
																	}
																	]
																	*/
														           	//_this.users=response.data;
														          	_this.restaurants=response.data;
													           	}).catch(function(){
													           		alert("加载内表,负责人信息出错了");
													           	});	 
												      },
														 //这个是显示查询的数据
														 querySearchAsync(queryString, cb) {

														        var restaurants = this.restaurants;				       
														        var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;	
														        
														      	console.log("results:"+results);//查看返回结果如果不为空则表示在当前列表中存在比配值，为空表示没有比配值									        
																        if(queryString==null||queryString.length==0){
														        		 
																        	 if(this.state1Flag){
																        		 //当不为空,触发解除搜索功能,且解除搜索没有触发
																        		 if(this.state1!=null&&this.removeSearch!=true){
																	        		 this.removeSearch=true;										        			 
																        		 }	
																        		 var obj=this.checkData();
																        		 if(obj.flag){
																				     if(this.select=='1'){	    															    	
																				    	 this.data.push('机会主题');
																				    	 this.data.push("%");
																				    	 this.withinSaleFindByTheme();
																				     }else if(this.select=='3'){
																				    	 this.data.push('报价主题');
																				    	 this.data.push("%");
																				    	 this. withinCompetitorFindByComName();	 
																				     }else{
																				    	 console.log("this.data:"+this.data);															    	 
																				    	 this.data.push('客户名称');
																				    	 this.data.push("%");
																						 this.withinsaleCustName();										    		 
																				     }													        			 
																        		 } 															    
																		    	 															     
					 
																        	 }
																			if(this.customerFlag){
																		    	 this.customer=null;
																		    	  this.abroadsaleCustName();
																						
																			}
																        	if(this.soltIdFlag){
																			     this.soltId=null;															    	 
																		    	 this.abroadsaleAddUnameInfo(); 												        	 		
																        	 }

							       
																	        clearTimeout(this.timeout);
																	        this.timeout = setTimeout(() => {
																	       	cb(this.restaurants);
																	       }, 3000* Math.random());	
																        }else{
																	      	if(results==''){
																	    	  console.log("queryString3:"+queryString);	
																	    	  if(this.state1Flag){
																	        		 var obj=this.checkData();
																	    		     if(obj.flag){
																					     if(this.select=='1'){
																					    	 this.data.push('机会主题');
																					    	 this.data.push(queryString);
																					    	 this.withinSaleFindByTheme();																    	 
																					     }else if(this.select=='3'){
																					    	 this.data.push('报价主题');
																					    	 this.data.push(queryString);
																					    	 this. withinCompetitorFindByComName();	 															    		 
																					     }else{																	    	 
																					    	 this.data.push('客户名称');
																					    	 this.data.push(queryString);
																							 this.withinsaleCustName();											    		 
																					     }														    		    	 
																	    		     }else{
																	    		    	 if(this.data[obj.index]=='不分组'){
																					    	 this.data[obj.index+1]=queryString;													    		    		 
																	    		    	 }else{
																					    	 this.data[obj.index]=queryString;														    		    		 
																	    		    	 }
																					     if(this.select=='1'){
																					    	 this.withinSaleFindByTheme();																    	 
																					     }else if(this.select=='3'){
																					    	 this. withinCompetitorFindByComName();	 															    		 
																					     }else{																	    	 
																							 this.withinsaleCustName();											    		 
																					     }	 
																	    		     }
																	    		  
																	    	  }
																			if(this.customerFlag){
																		    	 this.customer=queryString;
																		    	  this.abroadsaleCustName();																		
																			}
																	        if(this.soltIdFlag){
																			     this.soltId=queryString;;															    	 
																		    	 this.abroadsaleAddUnameInfo(); 
																        	 		
																	        }
																			        clearTimeout(this.timeout);
																			        this.timeout = setTimeout(() => {
																			       ;
																			       	cb(this.restaurants);
																			       }, 3000* Math.random());		     

																        }else{
																	        clearTimeout(this.timeout);
																	        this.timeout = setTimeout(() => {												     
																	       	cb(results);
																	       }, 1000* Math.random());
																	        
																        }
																	    	  
																    }						
														      },
														    //这个是根据输入的内容筛选数据
														   createStateFilter(queryString) {
														        return (state) => {return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);};
														      },	
												      //这里是数据筛选标签删除时的事件
												  removeTag(){
												    	  //console.log("item:"+item);	
												    	   console.log("触发removeTag数据筛选标签删除时的事件");
												    	  var _this=this;
												    	  var i=0;
												    	  console.log("value7的当前长度:"+_this.value7.length);
												    	  console.log("value7Copy的当前长度:"+_this.value7Copy.length);
												    	  console.log("value7:"+_this.value7);
												    	  console.log("value7Copy:"+_this.value7Copy);
												    	 var del=null;
												    	 //当value7为空时
												    	  if(_this.value7[0]==null){
												    		  //console.log("dd:"+_this.value7+"d");
												    		  console.log("条件搜索没有了呀，自动添加一个全部数据");
													    		_this.value7[0]='';	//表示添加一个全部数据									    		
														    	  console.log("olddata:"+_this.data.splice(1,1));	
													    		_this.data.push('');
													    		_this.removeSearch=false;
												    	  }
												    	 //查找被删除的值
												    		_this.value7Copy.find((a)=>{								    		  
												    		_this.value7.find((b)=>{ 
															   // console.log("被删除的值:"+b);								    			
												    			if(a!=b){
												    				del=a;

															    console.log("被删除的值del:"+del);	
												    			}
												    		
												    		}); 								    		 
												    	  });
												    	 
												    	  console.log("olddata:"+_this.data);								    	  
												    	  //删除data对等的数据
												    	  _this.data.find((c)=>{
												    		  if(del==c){
														    	  console.log("c:"+c);	
														    	  _this.data.splice(i-1,2);
												    		  }
												    		  i++;  

												    	  });								    	 								    	 
												    	  console.log("newdata:"+_this.data);
												    	  //同步copy值
												    	  _this.value7Copy=_this.value7;
												    	  console.log("新value7Copy:"+ _this.value7Copy);
												    	  var data=''+_this.data;
												    	  _this.tableloading=true;
													 	axios.get("/sales/quotationRecordPageable",
											           			//参数转换
										           			//Qs.stringify({ids:_this.value7}, {arrayFormat: 'indices'})
										           			{
											           		params:{
										          				pageNumber:1,
										          				pageCentent:4,		
											           			DId:data
											           		}
											           												 		
										           			}

											           			//json.stringify(this.form)
											           			//ajax请求成功的回调函数
											          			).then(function(response){
													           			console.log("回调成功，获取了服务器端返回的值v");
													           			console.log(response.data);
													           			//console.log(response.data.salesCount);/
															_this.tableData3=response.data.saleOpp;
															_this.page.AllpageNumber=response.data.salesCount;
											           	//	this.AllpageNumber=this.count/response.data.length;
											     		//  _this.tableData3 = response.data;	
															  _this.tableloading=false;
															_this.value7Copy=_this.value7;//copy值记录value的变化值
											           	}).catch(function(){
											           		//_this.form.customer=i;
											           		alert("筛选查询出错了");
											           	});									    	  
					
												      },
											//这个是列表的选择事件
											 handleSelect(item) {
											    	  /*
											    	  [
											    		  contacts:{
																con: '选项1',
																conlabel: '需求主题1'					
															},
															{
																con: '选项2',
																conlabel: '需求主题2'					
															}]
											    	  */
											    	  var _this=this;	
												     //   console.log("当前的item的数值:"); 	
												      //  console.log(); 								        
											    	  if(item!=null){
													        console.log("value7Flag:"+this.value7Flag); 
											    		  if(this.value7Flag){							    			
												    		  _this.multipleSelection1(item);  
											    		  }
											    		  if(this.state1Session==true){
											    			  	  this.clearData();//清除搜索框的搜索条件
																 _this.searchSelect(item);	
																 //this.removeSearch=true;	
											    		  }
											    	  }else{
											    		
											    	  }	
													 	
											    	  //这里是处理选择对应客户之后，相应的赋值
											    	  if(item.conName!=null){
											    		  console.log(item);
												    	  var contacts=[{con:item.label2,conlabel:item.conName}];
													        console.log("item:"+item.conName);
													        this.qrReceiver=contacts;		
													        this.form.qrReceiver=item.conName;
										           			this.conID=item.label2;
										           			this.form.qrOfferphone=item.tel;
											    	  }
												       if(item.label1!=null){
												        	  this.gdID=item.label1;
												        }
												    	  if(item.userId!=null){
												    		  this.userId=item.userId;
												    		  console.log("看看："+this.userId);
												    	  }
												      
												      },
												      //这里是处理多选条件的方法
												      multipleSelection1(item){
												    	  var _this=this;
												    	  console.log(item[item.length-1]);								    	  
												    		 var DId=item[item.length-1];
												    		  var i=0;
												    		  var count=new Array();
													    	  var obj=null,obj2=null;
									    					  var h=0,j=0;
															  console.log("value7:"+this.value7);
															  
															//  console.log("DId:"+DId);
															  //这里是所选值的循环
															  item.find((c)=>{
																  console.log("c:"+c);
																 // console.log("options3:"+_this.options3);
																  console.log("options3:"+_this.options3.length);
																  
																  //下面是的循环代码是判断在同一个父类字典信息中是否存在多个选中的值
																  
																  //这里是option3列表循环
																  _this.options3.find((b)=>{ 
																	  console.log("options3:"+i);
																	  //这里是options所有值的循环
															    	   _this.options3[i].options.find((a)=>{	
														    		   
															    		  console.log("测试："+c);
															    			 if(a.value===c){
																		    	   console.log("当前所在的options："+i);	
															    				// count++;//同一个options选中的值数
															    				 console.log("这个options存在于所选值相等的值");
															    				if(obj2==null){
															    					console.log("当前所在父类："+_this.options3[i].label);
																    				 obj2={value:i,count:1,OldDId:a.value,parent:_this.options3[i].label,newDId:''};
																    				 count.push(obj2);
																    				 console.log("初始化看看是什么：value="+count[0].value+"\tcount="+count[0].count+"\tDId="+count[0].DId);
															    				}else{
															    							
														    					var flag=count.find((j)=>{
														    						//当同一个options的值重复时，修改对应count数组的值即+1	
														    							if(j.value==i){
														    								j.count=2;
														    								j.newDId=a.value;
														    								console.log("看看count数组的值是否改变"+count[h].value+'\t'+count[h].count+"\tDId="+count[h].DId);
														    								return 1;
														    							}
														    							h++;
														    						});
														    						h=0;
														    						 if(flag!=null){
														    							 
														    						 }else{
																	    				 obj2={value:i,count:1,OldDId:a.value,parent:_this.options3[i].label,newDId:''};
																	    				 count.push(obj2);
																	    				 console.log("看看是什么：value="+obj2.value+"\tcount="+obj2.count+"\tDId="+obj2.DId);
														    						 }
															    				}

										    				 
															    			 }//a.value===c	

															    			 
																    	    });
															    	  console.log("obj:"+obj); 						
																	  i++;  //这里是options的自增索引值
																  });	
																  console.log("当前所选值结束列表循环-------------------------------------");
																  i=0;//将i重新赋值为0
															  });
															  this.removeSearch=true;
															  //这里我们厉遍我们记录的count数组
									    						count.find((it)=>{
																    console.log("count的当前循环次数:"+h);
																    if(it==null){
																    	return 0;
																    }
									    							//当选择的是全部数据时					    							
									    							if(it.OldDId==''){			    								
																	     console.log("选择的是全部数据:"+_this.value7.length);	
										    								if(_this.value7.length>1){
																			    console.log("count:"+count.length);
										    									count.splice(0,count.length-1);	
																			    console.log("count:"+count.length);	
																			    
										    								}else{					    									
																			     console.log("第一次选择非全部数据删除全部数据:");						    									
											    								 count.splice(h,1);				    									
										    								}
									    								_this.value7.splice(0,_this.value7.length-1);
									    								return 0;

									    							}
									    							
									    							//当同一个的options出现重复值时
									    							if(it.count==2){
														    			 _this.value7.find((b)=>{
																    		// console.log("obj:"+obj.value); 													    		 
													    				  if(b==it.OldDId){
													    					  console.log("odddddd:"+j.DId);								    					  
													    					 // console.log("obj2:"+_this.obj2.value); 										    					  
																		     console.log("所选值在改变之前的value7:"+ _this.value7); 
													    					  //_this.value7[j]=DId;
													    					  //_this.value7.pop();
													    					 // _this.value7[j]=null;
													    					 //arrayObj.splice(deletePos,deleteCount); //删除从指定位置deletePos开始的指定数量deleteCount的元素，数组形式返回所移除的元素
													    					_this.value7.splice(j,1);
												    					 	 //count.splice(j,1);
													    					  console.log("所选值在改变之后的value7:"+ _this.value7); 
													    					  //_this.obj2.value=obj.value;
													    				  }
												    						
													    				  j++;
													    			  });
														    			 j=0;
									    								//console.log("看看count数组的值是否改变"+count[h].value+'\t'+count[h].count);
									    							}
									    							h++;
											    							
									    						});
									    						this.option=count;
									
												      },

												      //这里是数据筛选下来宽事件
												  visibleChange(){
												    	  this.value7Flag=!this.value7Flag;
												    	  if(this.flag){
												    		  this.flag=false;
														 //copy值记录value的变化值
												    		  if(this.value7Copy==this.value7){
												    			  
												    		  }else{
													    		  this.screenQueries(); 								    			  
												    		  }
												    		  
												    	  }else{
												    		  this.flag=true;

												    	  }
												    	  
												      },    
												      //这里是解除搜索，显示全部数据的方法
												      removeSearch1(){
														//数据筛选下拉框，初始化为全部数据
														this.value7.splice(0,this.value7.length);										
														this.value7[0]='';
														this.value7Copy=this.value7;//copy值记录value的变化值
														this.option=[{count:1,OldDId:'',parent:'全部数据'}];
														//清除搜索条件，只保留“全部数据”这个条件
														this.data.splice(2,this.data.length);
														//调用数据筛选查询
														this.screenQueries();
														//将解除搜索按钮变为不可见
														this.removeSearch=false;
														//清除动态搜索框的输入数据
														this.state1=null;
												      },

														handleClick(row) {
															console.log(row);
														},
														handleSelectionChange(val) {
															//console.log("共:"+val);
															this.multipleSelection = val;
														},											      

														//这个是选择显示数据条数事件
														handleSizeChange(val) {
															var _this = this;
															this.tableloading=true;
															this.pageCententSelect=val;
															console.log("当前页: "+this.pageNumber);
															console.log("每页默认显示的条数:"+this.pageCententSelect);
															this.clearData();//剔除搜索宽里的分页条件
															var data=''+this.data;
														 	axios.get("/sales/quotationRecordPageable",
												           			{
												           		params: {
												          				pageNumber:this.pageNumber,
												          				pageCentent:this.pageCententSelect,
												          				DId:data
												          			    }
												           			}
												           			//ajax请求成功的回调函数
												          			).then(function(response){					          				
												           			console.log("回调成功，获取了服务器端返回的值v");
												           			console.log(response.data);
												           		//this.tableData3=response.data;					           		
																_this.tableData3=response.data.saleOpp;
																_this.page.AllpageNumber=response.data.salesCount;
												     		 _this.tableloading=false;
												           	}).catch(function(){
												           		alert("显示客户数据出错了");
												           	});
														},
														//这个是翻页事件
														handleCurrentChange(val) {
															var _this = this;
															this.pageNumber=val;
															this.tableloading=true;
															console.log("当前的分页条件: "+this.data);											
															console.log("当前页: "+val);
															console.log("每页默认显示的条数:"+this.pageCententSelect);
															this.clearData();//剔除搜索宽里的分页条件
															var data=''+this.data;
															  //post提交数据
												           	axios.get("/sales/quotationRecordPageable",
												           			{
												           		params: {
												          				pageNumber:this.pageNumber,
												          				pageCentent:this.pageCententSelect,
												          				DId:data
												          			    }
												           			}
												           			//ajax请求成功的回调函数
												          			).then(function(response){					          				
												           			console.log("回调成功，获取了服务器端返回的值v");
												           			console.log(response.data);
												           		//this.tableData3=response.data;
																_this.tableData3=response.data.saleOpp;
																_this.page.AllpageNumber=response.data.salesCount;
												     		 _this.tableloading=false;	
												           	}).catch(function(){
												           		alert("分页数据出错了");
												           	});
														},

													      print(obj){
													    	/*------------------------------------------*/
													    	//1.让新页面包含之前页面的引用
													    	//2.去掉多余的元素表格
																	 var _this=this;
																		 this.printFlag1=true;
				 													 setTimeout(function(){
																			// newWindow.print();
																			//window.print();	 
																		 _this.printFlag2=true;
																		 }, 300); 
																	 setTimeout(function(){
																			// newWindow.print();
																			//window.print();
																			
																	 var newWindow=window.open("销售机会列表","_blank");
																	 var docStr = document.getElementById("print").innerHTML;
				 													 newWindow.document.write(docStr);
																	 var styles=document.createElement("script");
																	 var link=document.createElement("link");
																	 var script=document.createElement("script");
																	 script.setAttribute('src','https://unpkg.com/element-ui/lib/index.js');
																	 
																	  styles.setAttribute('src','https://unpkg.com/vue/dist/vue.js');// media="print"
																	  
																	  
																	 link.setAttribute('rel','stylesheet');
																	 link.setAttribute('href','https://unpkg.com/element-ui/lib/theme-chalk/index.css');//.appendChild(link).appendChild(script)
																	 
																	  var styleContent=document.createElement("style");
																	  styleContent.setAttribute('type',"text/css");
																	  //width:1010px;height:369px;
																			styleContent.innerHTML="body{margin:0 auto;width:1080px;background:pink;}"			 		
																	 	//页面打印缩放比例设置
																	   //  document.getElementsByTagName('body')[0].style.zoom=0.92;
																	 	
																	 newWindow.document.getElementsByTagName('head')[0].appendChild(styles);	
																	 newWindow.document.getElementsByTagName('head')[0].appendChild(script);
																	 newWindow.document.getElementsByTagName('head')[0].appendChild(link);	
										
																	 newWindow.document.getElementsByTagName('head')[0].appendChild(styleContent);	
																	 //由于采用了引用，需要时间通过网络来获取样式加载，所以要给它加载的时间
																	 //不能采用sleep的方式，会导致浏览器资源被占用，无法加载通过网络获取的颜色		
																	 	 _this.printFlag1=false;
					 													 setTimeout(function(){	 
																			 _this.printFlag2=false;
																			 }, 200); 
																	 setTimeout(function(){

																		 newWindow.print();
																		 newWindow.close(); 
																		//window.print();	 
																	 }, 1000);																								
																		 //_this.printFlag2=true;
																		 }, 2000);
																	
						
													      },
													      
													      //
													      sleep(n){
													    	  var start = new Date().getTime();
													          //  console.log('休眠前：' + start);
													          while (true) {
													              if (new Date().getTime() - start > n) {
													                  break;
													              }
													            }
													      },
													      //表格列样式设置
													       //表格行样式设置	
													      cellStyle({row,rowIndex,column,columnIndex}){
													    	  //column是个对象
													      
													    	  //console.log(columnIndex);
													      
													    	  if(rowIndex==this.pageCententSelect-1){
													    		  return 'border:1px solid #ebeef5;'
													    	  } 									    	  
													    	  
													    	  if(columnIndex==0){
													    		  return 'border-left:1px solid #ebeef5;border-right:1px solid #ebeef5;border-top:1px solid #ebeef5'
													    	  }
													      
													    	  return 'border-right:1px solid #ebeef5;border-top:1px solid #ebeef5;border-left:1px solid #ebeef5'
													      
													    	  },							
														      //这里是加载外表，负责人的方法
														      abroadsaleAddUnameInfo(){
																	 /*
																	------------------加载负责人信息
																	 */	
																	 var _this=this;
																	 
																	 	axios.get("/sales/abroadsaleAddUnameInfo",
															           			//参数转换
															           			//Qs.stringify(this.form,{arrayFormat: 'brackets'})
															           			//ajax请求成功的回调函数
															           			{
																	 				params:{
																	 					uName: _this.qrOfferor
																	 				}
															           			}
															          			).then(function(response){					          				
															           			console.log("回调成功，获取了服务器端返回的值v");
															           			console.log("user:"+response.data);
																			/*
																			users:[
																			{
																				value: '选项1',
																				label: '用户名1'					
																			}
																			]
																			*/
																           	//_this.users=response.data;
																          	_this.restaurants=response.data;
															           		
															           	}).catch(function(){
															           		alert("加载外表,负责人信息出错了");
															           	});	  
														      },	
																//这个是新增以及修改 表单提交事件
														      submitForm(formName) {
																//alert(this.form.salStage);
																			var i=" ";
																    	    var obj = {};
																			var _this=this;
																		
																			i=this.form.customer;
																			this.form.customer=this.gdID;
																			var form = this.form;
																			
																			i=this.form.qrReceiver;
																			this.form.qrReceiver=this.conID;
																			 this.form.qrOfferor=this.userId;
																				if(_this.salesOpportunitys==null||_this.salesOpportunitys==0){
																					form.salesOpportunity=this.salId;										
																				}
																			/* i=this.form.salPossibility;
																			 this.form.salPossibility=this.salPossibilityValue;
																			 
																			 i=this.form.salSource;
																			 this.form.salSource=this.salSourceValue;
																			 
																			 i=this.form.salStage;
																			 this.form.salStage=this.salStageValue;
																			// salType
																			 i=this.form.salType;
																			 this.form.salType=this.salTypeValue;	*/							 
																			
																			//alert(form.salType);
																			 
														        this.$refs[formName].validate((valid) => {
														          if (valid) {
															            //alert('submit!');

													           			//console.log("log:"+Qs.stringify(this.form,{arrayat: 'brackets'}))		
													           			console.log(JSON.stringify(form));
																	 	axios.get("/sales/AddquotationRecord",
															           			//参数转换
															           			//Qs.stringify(this.form,{arrayFormat: 'brackets'})	
														           			{
														           		params:form 
														           			}


															           			//json.stringify(this.form)
															           			//ajax请求成功的回调函数
															          			).then(function(response){									    	  					          				
															          			_this.salesOpportunityTrackingLogs=null;					          			
															           			_this.$refs[formName].resetFields();//清空数据
																	           			console.log("回调成功，获取了服务器端返回的值v");
																	           			console.log(response.data);	
																	           			_this.dialogFormVisible=false;
																	           			_this.dialogrepair=false;
																	           			if(_this.form.salId==null){
																		           			_this.$notify({
																			           	          title: '添加成功',
																			           	          type: 'success',
																			           	       	  duration:3000
																			           	        });
																		           			_this.page.AllpageNumber=_this.page.AllpageNumber+1;
																	           			}else if(_this.form.salId!=null){
																		           			_this.$notify({
																			           	          title: '修改成功',
																			           	          type: 'success',
																			           	       	  duration:3000
																			           	        });
																	           			}else{
																	           				
																	           			}
																	           			
															           			/*
															           			-----------------------------刷新当前表单信息
															           			*/						           								           			
																				console.log("当前页: "+_this.pageNumber);
																				console.log("每页默认显示的条数:"+_this.pageCententSelect);
																				console.log("当id值: "+_this.form.salId);	
																				
																				if(_this.pageNumber==1||_this.form.salId!=null){
																					_this.tableloading=true;
																				 	axios.get("/sales/quotationRecordPageable",
																		           			{
																		           		params: {
																		          				pageNumber:_this.pageNumber,
																		          				pageCentent:_this.pageCententSelect,
																		          				DId:_this.DId
																		          			    }
																		           			}
																		           			//ajax请求成功的回调函数
																		          			).then(function(response){					          				
																		           			console.log("回调成功，获取了服务器端返回的值v");
																		           			console.log(response.data);
																							_this.tableData3=response.data.saleOpp;
																							_this.page.AllpageNumber=response.data.salesCount;
																		     		 _this.tableloading=false;
																		           	}).catch(function(){
																		           		alert("显示客户数据出错了");
																		           	});												
																				}
										

															           		//this.tableData3=response.data;					           		
															           	//	this.AllpageNumber=this.count/response.data.length;
															     		//  _this.tableData3 = response.data;					     							           					           	
															           	}).catch(function(){
															           		_this.form.customer=i;
															           		alert("新增表单提交出错了");
															           	});				        	  
														          } else {
														            console.log('error submit!!');
														            return false;
														          }
														        });
														      },														      
						},
					    //这里是页面初始化时加载数据的事件
						    mounted() {	
							this.data.push('全部数据');
							this.data.push('');
							//这里是加载主题名称信息
					    	this.withinSaleFindByTheme();
							//加载负责人信息
							//this.loadUsers();
							//数据筛选下拉框，初始化为全部数据
							this.value7[0]='';
							this.value7Copy=this.value7;//copy值记录value的初始化值,数据筛选下拉框
							this.valueCopy=this.state1;//copy值记录value的初始化值,搜索框

					           	
							//获取当前登录用户的编号
							var arr=new Array();
							var Id='';
								arr=document.cookie;
								console.log("当前用户的cookie:"+arr);
							/*	for(var i=0;i<arr.length;i++){
									if(arr[i]==";"){
										Id=arr.slice(i,arr.length)
									}
								}
								//获取当前登录用户的编号
								console.log("当前用户的cookie:"+Id);*/

						},			
					}
					var Ctor = Vue.extend(Main1)
					//bigbox
					new Ctor().$mount('#bigbox')
/*---------------------------------------------------------------------------------------------------------------------*/							   
							   
		</script>					
</body>
</html>